package es.udc.pfc.davidparedes.model.receptionist;

import java.util.Calendar;
import java.util.List;

import org.springframework.stereotype.Repository;

import es.udc.pfc.davidparedes.model.dao.GenericDaoHibernate;

@Repository("receptionistDao")
public class ReceptionistDaoHibernate extends
		GenericDaoHibernate<Receptionist, Long> implements ReceptionistDao {
	
	@SuppressWarnings("unchecked")
	public List<Receptionist> findReceptionistsByStore(Long storeId) {
		
		Calendar now = Calendar.getInstance();
		return getSession()
				  .createQuery(
				  "SELECT r FROM Receptionist r WHERE "
				  + "r.contractTermination > :now "
				  + "AND r.store.storeId = :storeId")
				  .setParameter("storeId", storeId)
				  .setCalendar("now", now)
				  .list();
	}
	
}